package cn.copera.dyy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.copera.dyy.common.service.BaseService;
import cn.copera.dyy.dao.ExchangeRuleDao;
import cn.copera.dyy.entity.ExchangeRule;

/**
 * 店铺兑换规则Service
 * 
 */
@Service
@Transactional(readOnly = true)
public class ExchangeRuleService extends BaseService {

	@Autowired
	private ExchangeRuleDao exchangeRuleDao;
	public ExchangeRule get(String id) {
		return exchangeRuleDao.get(id);
	}
	@Transactional(readOnly = false)
	public void save(ExchangeRule exchangeRule) {
		exchangeRuleDao.clear();
		exchangeRuleDao.save(exchangeRule);
	}
	
	public List<ExchangeRule> findById(String id){
		return exchangeRuleDao.find("from ExchangeRule where shop.id = '"+id+"'");
	}
	
	@Transactional(readOnly = false)
	public void deleteById(String id){
		exchangeRuleDao.deleteRealById(id);
	}

}
